<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
require './class.phpmailer.php';
require './class.smtp.php';
require './class.pop3.php';

$conf = parse_ini_file("../model-db-connection/configuration.ini");
$contactName = $_POST['contact_name'];
$contactEmail = $_POST['contact_email'];
$contactSubject = $_POST['contact_subject'];
$contactPhone = $_POST['contact_phone'];
$contactMessage = $_POST['contact_message'];

$mail = new PHPMailer();

$mail->IsSMTP();                                      // set mailer to use SMTP
$mail->Host = "mail.swissmooh.co.th";  // specify main and backup server
$mail->SMTPAuth = true;     // turn on SMTP authentication
$mail->Username = "support@swissmooh.co.th";  // SMTP username
$mail->Password = "Welcome1"; // SMTP password

$mail->From = $contactEmail;
$mail->FromName = $contactName;
$mail->AddAddress($conf['email.from'], $conf['email.from.name']);
//$mail->AddAddress("ellen@example.com");                  // name is optional
//$mail->AddReplyTo("info@example.com", "Information");
//$mail->WordWrap = 50;                                 // set word wrap to 50 characters
//$mail->AddAttachment("/var/tmp/file.tar.gz");         // add attachments
//$mail->AddAttachment("/tmp/image.jpg", "new.jpg");    // optional name
$mail->IsHTML(true);                                  // set email format to HTML

$mail->Subject = $contactSubject;
$mail->Body = $contactMessage;

if (!$mail->Send()) {
    echo "Message could not be sent. <p>";
    echo "Mailer Error: " . $mail->ErrorInfo;
    exit;
}

echo "Message has been sent from " . $contactEmail;
